<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/jquery-3.6.0.js"></script>
  </head>
  <body>
    <a href="http://www.baidu.com" id="a1">去百度1</a>
    <a href="javaScript:" id="a2">去百度2</a>
  </body>
</html>
<script>
  $('#a1').click(function () {
    alert('测试事件默认行为111')
    event.preventDefault()
  })

  $('#a2').click(function () {
    alert('测试事件默认行为222')
  })
</script>
